<template>
	<view>
		<view v-if='pageData'>
			<view class="banner-box" v-if='pageData.merMemo && pageData.merMemo.length > 0'>
				<swiper class="banner" :autoplay="true"
				:interval="3000" :duration="666"
				circular="true" @change="change"
				previous-margin='30rpx' next-margin='30rpx'>
					<swiper-item class="flex-box align-center" v-for="(item,i) in pageData.merMemo" :key='i'>
						<image :src="$imgUrls(item)" mode="aspectFill" :class="{scale: current != i}"></image>
					</swiper-item>
				</swiper>
			</view>
			<view class="list">
				<view class="title">{{ pageData.name }}</view>
				<view class="item">
					<text>{{ pageData.address }}</text>
				</view>
				<view class="item flex-box align-center" @click="update('fPrice','店铺运费',pageData.fPrice)">
					<text class="flex">店铺运费</text>
					<text>{{ pageData.fPrice }}元</text>
					<text class="iconfont icon-more"></text>
				</view>
				<view class="item flex-box align-center" @click="update('phone','门店电话',pageData.phone)">
					<text class="flex">门店电话</text>
					<text>{{ pageData.phone }}</text>
					<text class="iconfont icon-more"></text>
				</view>
				<navigator url="./orderInform" hover-class="none" class="item flex-box align-center">
					<text class="flex">订单通知</text>
					<text class="iconfont icon-more"></text>
				</navigator>
				<navigator url="./updatePwd" hover-class="none" class="item flex-box align-center">
					<text class="flex">修改密码</text>
					<text class="iconfont icon-more"></text>
				</navigator>
			</view>
		</view>
		<empty type='1' v-if='noData' :msg='errmsg'></empty>
		
		
		<view class="mask flex-box flex-center align-center" v-if='showAdjustment' @click="showAdjustment = false">
			<view class="adjustment" @click.stop>
				<view class="title">修改{{title}}</view>
				<view class="msg">
					<view class="item flex-box align-center">
						<input type="text" v-model="value" :placeholder="'请输入要修改的'+title" placeholder-class="pla"/>
					</view>
				</view>
				<view class="btns flex-box">
					<view class="cancel" @click="showAdjustment = false">取消</view>
					<view class="ok" @click="WriteOff">确定</view>
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	var that;
	export default {
		data() {
			return {
				showAdjustment: false,
				title: '',
				type: '',
				value:'',
				
				
				current: 0,
				banner:[
					'','',''
				],
				noData: false,
				errmsg:'',
				pageData:''
			};
		},
		onLoad() {
			that = this
			that.getStoreIndex()
			// #ifdef H5
			this.$common.H5HideShare()
			// #endif
		},
		methods:{
			update(key, title ,val){
				that.type = key
				that.showAdjustment = true
				if(val)
					that.value = val
				that.title = title
			},
			WriteOff(){
				if(!that.value.trim()){
					uni.showToast({title:that.title+'不能为空！',icon:'none'})
					return
				}
				// if(that.type == 'phone'){
				// 	if(!that.$reg.phone.test(that.value)){
				// 		uni.showToast({title:'手机号码格式有误',icon:'none'})
				// 		return
				// 	}
				// }
				var param = {
					shop_id: uni.getStorageSync('store_id'),
					type: that.type
				}
				param[that.type] = that.value
				that.$http.post({
					url: '/singleSaleManageApi/storeEdit',
					data: param
				}).then(res => {
					if(res.code == 200){
						that.showAdjustment = false
						that.getStoreIndex()
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none'
						})
					}
				})
			},
			change(e){
				that.current = e.detail.current
			},
			getStoreIndex(){
				that.noData = false
				that.$http.get({
					url: '/singleSaleManageApi/storeConfig',
					data:{
						shop_id: uni.getStorageSync('store_id')
					}
				}).then(res => {
					if (res.code == 200) {
						that.pageData = res.data
					}else{
						that.errmsg = res.msg
						that.noData = true
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.page{
		background-color: #ffffff;
	}
	.banner-box{
		padding: 20rpx 0;
		background-color: #F5F5F5;
		.banner{
			swiper-item{
				padding: 10rpx;
				height: 100%;
			}
			
			height: 334rpx;
			image{
				width: 100%;
				height: 100%;
				border-radius: 24rpx;
				transition: all .3s;
			}
			.scale{
				height: 242rpx;
			}
		}
	}
	.list{
		.title{
			font-size: $font-size-lg;
			padding: 40rpx $page-space;
			border-bottom: 1px solid #F5F5F5;
		}
		.item{
			padding: 28rpx $page-space;
			border-bottom: 1px solid #F5F5F5;
			text{
				font-size: 28rpx;
			}
			.icon-more{
				position: relative;
				top: 2rpx;
				margin-left: 30rpx;
			}
		}
	}

	.adjustment{
		background-color: #FFFFFF;
		width: 590rpx;
		border-radius: $border-radius-base;
		overflow: hidden;
		.title{
			text-align: center;
			padding: 48rpx 0;
			font-size: 36rpx;
			font-weight: 600;
		}
		.msg{
			padding: 0 30rpx;
			.item{
				margin-top: 28rpx;
				height: 88rpx;
				border-radius: 44rpx;
				border: 1px solid #EEEEEE;
				padding: 0 30rpx;
				input{
					height: 100%;
					font-size: 28rpx;
				}
			}
		}
		.btns{
			height: 88rpx;
			line-height: 88rpx;
			margin-top: 50rpx;
			.cancel{
				color: #4C4C4C;
				font-size: 32rpx;
				flex: 1;
				text-align: center;
				border-top: 1px solid #EEEEEE;
			}
			.ok{
				flex: 1;
				text-align: center;
				color: #FFFFFF;
				background-color: $uni-color-primary;
				font-size: 32rpx;
			}
		}
	}
</style>
